Skip to content

[EngSys] Use .ts extensions for samples-dev relative imports - from claude#38824

Open
jeremymeng wants to merge 2 commits into
Azure:mainfrom
jeremymeng:jeremymeng/fix-samples-dev-imports
Open

[EngSys] Use .ts extensions for samples-dev relative imports - from claude#38824
jeremymeng wants to merge 2 commits into
Azure:mainfrom
jeremymeng:jeremymeng/fix-samples-dev-imports

Conversation

@jeremymeng
Copy link
Copy Markdown
Member

Summary

Fixes #38822.

  • Switched relative imports in samples-dev from .js to .ts so that dev-tool samples run, which now loads samples directly via Node's TypeScript loader (Node 22.18+), can resolve them.
  • Added allowImportingTsExtensions: true to the shared tsconfig.samples.base.json so tsc -p tsconfig.samples.json continues to accept samples-dev/**/*.ts sources.
  • Updated dev-tool samples publish so the resulting samples/ tree continues to use .js specifiers: relative .ts imports are rewritten to .js in both the TypeScript output (which is compiled with tsc using nodenext resolution) and the JavaScript (CommonJS) output. The generated tsconfig.json also strips allowImportingTsExtensions.
  • Added a ts-imports test fixture under common/tools/dev-tool/test/samples/files/ that exercises the rewrite for both kinds of published output.

Test plan

  • pnpm test in common/tools/dev-tool (46 tests pass, including the new ts-imports fixture).
  • Manually published the attestation package's samples and confirmed samples/v1/typescript/src/*.ts and samples/v1/javascript/*.js both reference ./utils/*.js.
  • Loaded an attestation sample directly with Node's TS loader and confirmed the original ERR_MODULE_NOT_FOUND on ./utils/helpers.js no longer reproduces.

🤖 Generated with Claude Code

`dev-tool samples run` now executes samples directly via Node's TypeScript
loader, which requires `.ts` extensions for relative imports. Switch all
samples-dev sources with relative imports to `.ts` and enable
`allowImportingTsExtensions` in the shared samples tsconfig.

When publishing samples, the dev-tool now rewrites `.ts` specifiers back
to `.js` (and strips `allowImportingTsExtensions` from the generated
tsconfig), so published samples continue to compile with `tsc` and run as
plain CommonJS JavaScript.

Fixes Azure#38822.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@jeremymeng jeremymeng marked this pull request as draft June 4, 2026 18:35
@jeremymeng jeremymeng changed the title [EngSys] Use .ts extensions for samples-dev relative imports [EngSys] Use .ts extensions for samples-dev relative imports - from claude Jun 4, 2026
@github-actions github-actions Bot added App Configuration Azure.ApplicationModel.Configuration Attestation Cognitive - Form Recognizer Cosmos dev-tool Issues related to the Azure SDK for JS dev-tool Event Hubs Search Storage Storage Service (Queues, Blobs, Files) labels Jun 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot stopped reviewing on behalf of jeremymeng due to an error June 4, 2026 19:35
to have `"allowImportingTsExtensions": true`
@jeremymeng jeremymeng marked this pull request as ready for review June 4, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App Configuration Azure.ApplicationModel.Configuration Attestation Cognitive - Form Recognizer Cosmos dev-tool Issues related to the Azure SDK for JS dev-tool Event Hubs Search Storage Storage Service (Queues, Blobs, Files)

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

[EngSys] execute samples failures when samples import from other module

2 participants